﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
           // DirectoryInfo directoryInfo = new DirectoryInfo("D:\\mySolo");
           // directoryInfo.Create();
            bool flag = Directory.Exists("D:\\mySolo");
            if (flag)
            {
                Console.WriteLine("存在文件");
            }
            else
            {
                Directory.CreateDirectory("D:\\mySolo");
            }

            FileInfo fileInfo = new FileInfo("D:\\mySolo\\test.txt");
            fileInfo.Create().Close();    //创建文件

            // FileStream fileStream = new FileStream("D:\\mySolo\\test.txt",FileMode.OpenOrCreate, FileAccess.ReadWrite);

            var a = @"D:\\mySolo\\test.txt";
            StreamWriter streamWriter = new StreamWriter(a);
            streamWriter.WriteLine("小鸭子");
            streamWriter.WriteLine("一只二只三只");
            streamWriter.WriteLine("数也数不清");
            //刷新缓存
            streamWriter.Flush();
            //关闭流
            streamWriter.Close();
        }
    }
}
